﻿using System;
using System.Windows;
using YwangHRMSys.DAL;
using YwangHRMSys.DBUtility;
using YwangHRMSys.Model;
using YwangHRMSys.UI.EmployeeMgr;
using YwangHRMSys.UI.EmployeeMgr.AddressInfoMgr;
using YwangHRMSys.UI.LoginMgr;
using YwangHRMSys.UI.SystemMgr;
using YwangHRMSys.UI.SystemMgr.CategoryMgr;
using YwangHRMSys.UI.SystemMgr.ContractMgr;
using YwangHRMSys.UI.SystemMgr.DepartmentMgr;


namespace YwangHRMSys.UI
    {
        /// <summary>
        ///     MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
            {

                public MainWindow()
                {
                    InitializeComponent();
                }


                private void Window_Loaded( object sender, RoutedEventArgs e )
                {
                    #region 登录判断

                    //登录界面打开
                    var loginWindow = new LoginWindow();
                    if (loginWindow.ShowDialog() != true)
                        {
                            //退出程序
                            Application.Current.Shutdown();
                            //当用户取消登录时，不再去获取session中的值
                            return;
                        }

                    #endregion

                    //获取到session中的登录用户的值
                    Guid operatorId = CommonHelper.GetOperatorId();
                 //   OperatorInfoModel model = new OperatorInfoDAL().GetById(operatorId);
                    //当用户名等于“admin”时，权限最大化
                  
                    AdminPermissionModel adminModel = new AdminPermissionDal().GetByAdminPermissionID(operatorId);
                  
                //    Guid id = adminModel.Id;
                 
                   // string adminName = adminModel.UserName;


                    if (adminModel != null)
                        {
                            MeOperatorMgr.Visibility = Visibility;

                        }
                        

                }

                private void MeOperatorMgr_Click( object sender, RoutedEventArgs e )
                {
                    #region 操作员管理

                    var window = new LoginWindowList();
                    window.ShowDialog();

                    #endregion
                }

                private void MeEmployee_Click( object sender, RoutedEventArgs e )
                {
                    #region 员工管理

                    var win = new EmployeeWindowList();
                    win.ShowDialog();

                    #endregion
                }

                private void MeCategory_Click( object sender, RoutedEventArgs e )
                {
                    #region 类别管理

                    var win = new CategoryWindowList();
                    win.ShowDialog();

                    #endregion
                }

                private void MeDepartment_Click( object sender, RoutedEventArgs e )
                {
                    var depart = new DepartmentWindowList();
                    depart.ShowDialog();
                }

                private void MeContract_Click( object sender, RoutedEventArgs e )
                {
                    var contract = new ContractInfoWindowList();
                    contract.ShowDialog();
                }

                private void MeEmployeeAdd_Click( object sender, RoutedEventArgs e )
                {
                    var win = new EmployeeWindowEdit();
                    win.ShowDialog();
                }

                private void MeDomicile_Click( object sender, RoutedEventArgs e )
                {
                    var win = new AddressEditWindow();
                    win.ShowDialog();
                }

            }
    }